/*
 * 类名称:RegionRelateBedroomServiceImpl.java
 * 包名称:com.platform.service.impl
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2019-08-28 15:14:28        lipengjun     初版做成
 *
 * Copyright (c) 2019-2019 微同科技
 */
package com.platform.service.impl;

import com.alibaba.druid.pool.WrapperAdapter;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.dao.SysMenuDao;
import com.platform.utils.QueryPlus;
import com.platform.dao.RegionRelateBedroomDao;
import com.platform.entity.RegionRelateBedroomEntity;
import com.platform.service.RegionRelateBedroomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import sun.invoke.WrapperInstance;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 区域学校寝室楼关联表Service实现类
 *
 * @author sunkaichun
 * @date 2019-08-28 15:14:28
 */
@Service("regionRelateBedroomService")
public class RegionRelateBedroomServiceImpl extends ServiceImpl<RegionRelateBedroomDao, RegionRelateBedroomEntity> implements RegionRelateBedroomService {

    @Autowired
    private RegionRelateBedroomDao regionRelateBedroomDao;

    @Override
    public List<RegionRelateBedroomEntity> queryAll(Map<String, Object> params) {
        QueryWrapper<RegionRelateBedroomEntity> regionWrapper= new QueryWrapper<RegionRelateBedroomEntity>();
        regionWrapper.eq("type",params.get("type"));
        baseMapper.selectOne(regionWrapper);
        return baseMapper.queryAll(params);
    }
    @Override
    public List<RegionRelateBedroomEntity> queryAllSchool() {
        QueryWrapper<RegionRelateBedroomEntity> regionWrapper= new QueryWrapper<RegionRelateBedroomEntity>();
        regionWrapper.eq("type",2);
        return  baseMapper.selectList(regionWrapper);
    }
    @Override
    public List<RegionRelateBedroomEntity> queryAllDorm() {
        QueryWrapper<RegionRelateBedroomEntity> regionWrapper= new QueryWrapper<RegionRelateBedroomEntity>();
        regionWrapper.eq("type",3);
        return  baseMapper.selectList(regionWrapper);
    }

    @Override
    public Page queryPage(Map<String, Object> params) {
        //排序
        params.put("sidx", "T.id");
        params.put("asc", false);
        Page<RegionRelateBedroomEntity> page = new QueryPlus<RegionRelateBedroomEntity>(params).getPage();
        return page.setRecords(baseMapper.selectRegionRelateBedroomPage(page, params));
    }

    @Override
    public boolean add(RegionRelateBedroomEntity regionRelateBedroom) {
        return this.save(regionRelateBedroom);
    }

    @Override
    public boolean update(RegionRelateBedroomEntity regionRelateBedroom) {
        return this.updateById(regionRelateBedroom);
    }

    @Override
    public boolean delete(Integer id) {
        return this.removeById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteBatch(Integer[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }

    @Override
    public List<RegionRelateBedroomEntity> queryNotBedRoomList() {
        return regionRelateBedroomDao.queryNotBedRoomList();
    }
}
